name: TF_LOG=DEBUG check
on:
  issues:
    types: [opened, labeled, edited]
  workflow_dispatch:
    inputs:
      issue_number:
        description: The issue to target
        required: true
jobs:
  tf-log-check:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Set up Go
        uses: actions/setup-go@v5
        with:
          go-version-file: 'tools/go.mod'
      - run: make tools
      - name: Set the issue number to test
        run: |
          if [ -n "${{ github.event.inputs.issue_number }}" ]; then
              echo "issue_number=${{ github.event.inputs.issue_number }}" >> $GITHUB_ENV
          else
              echo "issue_number=${{ github.event.issue.number }}" >> $GITHUB_ENV
          fi
      - run: go run cmd/tf-log-check/main.go ${{ env.issue_number }}
        working-directory: ./tools
        env:
          GITHUB_OWNER: cloudflare
          GITHUB_REPO: terraform-provider-cloudflare
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
